package gui.view;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;

import gui.controller.actions.BuySellAction;
import gui.controller.actions.ExitAction;
import gui.controller.actions.LoginAction;
import gui.controller.actions.RegisterAction;
import gui.controller.actions.ViewAction;
import gui.controller.actions.WithdrawAction;
import gui.model.model;

import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class mainFrame extends JFrame{

	private JPanel topPanel;
	
	private JButton btnBuySell;
	private JButton btnLogin;
	private JButton btnRegister;
	private JButton btnView;
	private JButton btnWithdraw;
	private JButton btnExit;
	
	private Action buySellAction;
	private Action loginAction;
	private Action registerAction;
	private Action viewAction;
	private Action withdrawAction;
	private Action exitAction;
	
	public mainFrame(model m)
	{
		buySellAction = new BuySellAction(m); //create button actions
		loginAction = new LoginAction(m);
		registerAction = new RegisterAction(m);
		viewAction = new ViewAction(m);
		withdrawAction = new WithdrawAction(m);
		exitAction = new ExitAction(m);
		
		btnBuySell = new JButton(buySellAction);
		btnLogin = new JButton(loginAction);
		btnRegister = new JButton(registerAction);
		btnView = new JButton(viewAction);
		btnWithdraw = new JButton(withdrawAction); //create buttons with actions
		btnExit = new JButton(exitAction);
		
		btnBuySell.setText("Buy/Sell Stocks");
		btnLogin.setText("Login");
		btnRegister.setText("Register");
		btnView.setText("View Stocks");
		btnWithdraw.setText("Withdraw Stocks"); //set button text
		btnExit.setText("Exit");
		
		topPanel = new JPanel();
    	topPanel.setPreferredSize(new Dimension(400,700));
    	topPanel.setLayout(new GridLayout(3,2));
    	getContentPane().add(topPanel); //create panels and add them to frame
    	
    	topPanel.add(btnLogin);
    	topPanel.add(btnRegister);
    	topPanel.add(btnBuySell);
    	topPanel.add(btnView);
    	topPanel.add(btnWithdraw); //add buttons to panel
    	topPanel.add(btnExit);
    	
    	this.setTitle("Stock Market Client: v0.1");
    	this.setResizable(false);
    	this.setSize(400,400);
    	this.setLocationRelativeTo(null); //set frame to middle of screen
    	this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    	
	}
}
